﻿#region Using Directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;

using NetROS.Tiers.Entities;
using NetROS.Tiers.Data;
using NetROS.Tiers.Data.Bases;
using NetROS.Tiers.Services;
#endregion

namespace NetROS.Tiers.Web.Data
{
	/// <summary>
	/// Represents the DataRepository.DokumentProvider object that provides
	/// data to data-bound controls in multi-tier Web application architectures.
	/// </summary>
	[Designer(typeof(DokumentDataSourceDesigner))]
	public class DokumentDataSource : ProviderDataSource<Dokument, DokumentKey>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the DokumentDataSource class.
		/// </summary>
		public DokumentDataSource() : base(new DokumentService())
		{
		}

		#endregion Constructors
		
		#region Properties
		
		/// <summary>
		/// Gets a reference to the DokumentDataSourceView used by the DokumentDataSource.
		/// </summary>
		protected DokumentDataSourceView DokumentView
		{
			get { return ( View as DokumentDataSourceView ); }
		}
		
		/// <summary>
		/// Gets or sets the name of the method or function that
		/// the DokumentDataSource control invokes to retrieve data.
		/// </summary>
		public DokumentSelectMethod SelectMethod
		{
			get
			{
				DokumentSelectMethod selectMethod = DokumentSelectMethod.GetAll;
				Object method = ViewState["SelectMethod"];
				if ( method != null )
				{
					selectMethod = (DokumentSelectMethod) method;
				}
				return selectMethod;
			}
			set { ViewState["SelectMethod"] = value; }
		}

		#endregion Properties
		
		#region Methods

		/// <summary>
		/// Creates a new instance of the DokumentDataSourceView class that is to be
		/// used by the DokumentDataSource.
		/// </summary>
		/// <returns>An instance of the DokumentDataSourceView class.</returns>
		protected override BaseDataSourceView<Dokument, DokumentKey> GetNewDataSourceView()
		{
			return new DokumentDataSourceView(this, DefaultViewName);
		}
		
		/// <summary>
        /// Creates a cache hashing key based on the startIndex, pageSize and the SelectMethod being used.
        /// </summary>
        /// <param name="startIndex">The current start row index.</param>
        /// <param name="pageSize">The current page size.</param>
        /// <returns>A string that can be used as a key for caching purposes.</returns>
		protected override string CacheHashKey(int startIndex, int pageSize)
        {
			return String.Format("{0}:{1}:{2}", SelectMethod, startIndex, pageSize);
        }
		
		#endregion Methods
	}
	
	/// <summary>
	/// Supports the DokumentDataSource control and provides an interface for
	/// data-bound controls to perform data operations with business and data objects.
	/// </summary>
	public class DokumentDataSourceView : ProviderDataSourceView<Dokument, DokumentKey>
	{
		#region Declarations

		#endregion Declarations
		
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the DokumentDataSourceView class.
		/// </summary>
		/// <param name="owner">A reference to the DokumentDataSource which created this instance.</param>
		/// <param name="viewName">The name of the view.</param>
		public DokumentDataSourceView(DokumentDataSource owner, String viewName)
			: base(owner, viewName)
		{
		}
		
		#endregion Constructors
		
		#region Properties

		/// <summary>
		/// Gets a strongly-typed reference to the Owner property.
		/// </summary>
		internal DokumentDataSource DokumentOwner
		{
			get { return Owner as DokumentDataSource; }
		}

		/// <summary>
		/// Gets or sets the name of the method or function that
		/// the DataSource control invokes to retrieve data.
		/// </summary>
		internal DokumentSelectMethod SelectMethod
		{
			get { return DokumentOwner.SelectMethod; }
			set { DokumentOwner.SelectMethod = value; }
		}

		/// <summary>
		/// Gets a strongly typed reference to the Provider property.
		/// </summary>
		internal DokumentService DokumentProvider
		{
			get { return Provider as DokumentService; }
		}

		#endregion Properties
		
		#region Methods
		
		/// <summary>
		/// Gets a collection of Entity objects based on the value of the SelectMethod property.
		/// </summary>
		/// <param name="count">The total number of rows in the DataSource.</param>
		/// <returns>A collection of Entity objects.</returns>
		protected override IList<Dokument> GetSelectData(out int count)
		{
			Hashtable values = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
			Hashtable customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
			IList<Dokument> results = null;
			Dokument item;
			count = 0;
			
			System.Int32 iD;
			System.Int32 iDDokumentTip;
			System.Int32 iDStatus;
			System.DateTime datum;
			System.Int32 dokumentMijenjaCijenu;
			System.DateTime dateModified;
			System.Int32 iDUserIzdao;
			System.Int32? iDNacinPlacanja_nullable;
			System.Int32? iDNacinTransporta_nullable;
			System.Int32? iDKlijent_nullable;
			System.Int32? iDOrganizacijaZiroRacun_nullable;
			System.Int32? iDValute_nullable;
			System.Int32? iDOrganizacijaOd_nullable;
			System.Int32? iDOrganizacijaPrema_nullable;
			System.Int32? iDUserPrimio_nullable;
			System.Int32 iDParent;
			System.Int32 iDChild;
			System.Int32? sp36_IDDokumentToFind;
			System.Int32? sp39_IDDokument;
			System.Int32? sp39_IDDokumentTipStorno;
			System.DateTime? sp35_DatumOd;
			System.Int32? sp38_IDReversToFind;

			switch ( SelectMethod )
			{
				case DokumentSelectMethod.Get:
					DokumentKey entityKey  = new DokumentKey();
					entityKey.Load(values);
					item = DokumentProvider.Get(entityKey);
					results = new TList<Dokument>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case DokumentSelectMethod.GetAll:
                    results = DokumentProvider.GetAll(StartIndex, PageSize, out count);
                    break;
				case DokumentSelectMethod.GetPaged:
					results = DokumentProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
					break;
				case DokumentSelectMethod.Find:
					if ( FilterParameters != null )
						results = DokumentProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
					else
						results = DokumentProvider.Find(WhereClause, StartIndex, PageSize, out count);
                    break;
				// PK
				case DokumentSelectMethod.GetByID:
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					item = DokumentProvider.GetByID(iD);
					results = new TList<Dokument>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				// IX
				case DokumentSelectMethod.GetByIDDokumentTipIDStatusIDDatum:
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					datum = ( values["Datum"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["Datum"], typeof(System.DateTime)) : DateTime.MinValue;
					results = DokumentProvider.GetByIDDokumentTipIDStatusIDDatum(iDDokumentTip, iDStatus, iD, datum, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDStatusIDIDDokumentTipDatum:
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					datum = ( values["Datum"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["Datum"], typeof(System.DateTime)) : DateTime.MinValue;
					results = DokumentProvider.GetByIDStatusIDIDDokumentTipDatum(iDStatus, iD, iDDokumentTip, datum, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDStatus:
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByIDStatus(iDStatus, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByDokumentMijenjaCijenuDatumDateModifiedIDIDStatusIDDokumentTip:
					dokumentMijenjaCijenu = ( values["DokumentMijenjaCijenu"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["DokumentMijenjaCijenu"], typeof(System.Int32)) : (int)0;
					datum = ( values["Datum"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["Datum"], typeof(System.DateTime)) : DateTime.MinValue;
					dateModified = ( values["DateModified"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["DateModified"], typeof(System.DateTime)) : DateTime.MinValue;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByDokumentMijenjaCijenuDatumDateModifiedIDIDStatusIDDokumentTip(dokumentMijenjaCijenu, datum, dateModified, iD, iDStatus, iDDokumentTip, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDIDDokumentTip:
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByIDIDDokumentTip(iD, iDDokumentTip, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDDokumentTipIDIDStatus:
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByIDDokumentTipIDIDStatus(iDDokumentTip, iD, iDStatus, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByDatumIDDokumentTipIDStatusIDDateModified:
					datum = ( values["Datum"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["Datum"], typeof(System.DateTime)) : DateTime.MinValue;
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					dateModified = ( values["DateModified"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["DateModified"], typeof(System.DateTime)) : DateTime.MinValue;
					results = DokumentProvider.GetByDatumIDDokumentTipIDStatusIDDateModified(datum, iDDokumentTip, iDStatus, iD, dateModified, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDStatusDatumIDDokumentTipIDDateModified:
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					datum = ( values["Datum"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["Datum"], typeof(System.DateTime)) : DateTime.MinValue;
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					dateModified = ( values["DateModified"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["DateModified"], typeof(System.DateTime)) : DateTime.MinValue;
					results = DokumentProvider.GetByIDStatusDatumIDDokumentTipIDDateModified(iDStatus, datum, iDDokumentTip, iD, dateModified, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDDokumentTipIDStatusDatumIDDateModified:
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					datum = ( values["Datum"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["Datum"], typeof(System.DateTime)) : DateTime.MinValue;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					dateModified = ( values["DateModified"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["DateModified"], typeof(System.DateTime)) : DateTime.MinValue;
					results = DokumentProvider.GetByIDDokumentTipIDStatusDatumIDDateModified(iDDokumentTip, iDStatus, datum, iD, dateModified, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDDokumentTipIDStatusDatumID:
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					iDStatus = ( values["IDStatus"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDStatus"], typeof(System.Int32)) : (int)0;
					datum = ( values["Datum"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["Datum"], typeof(System.DateTime)) : DateTime.MinValue;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByIDDokumentTipIDStatusDatumID(iDDokumentTip, iDStatus, datum, iD, this.StartIndex, this.PageSize, out count);
					break;
				// FK
				case DokumentSelectMethod.GetByIDUserIzdao:
					iDUserIzdao = ( values["IDUserIzdao"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDUserIzdao"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByIDUserIzdao(iDUserIzdao, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDNacinPlacanja:
					iDNacinPlacanja_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDNacinPlacanja"], typeof(System.Int32?));
					results = DokumentProvider.GetByIDNacinPlacanja(iDNacinPlacanja_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDNacinTransporta:
					iDNacinTransporta_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDNacinTransporta"], typeof(System.Int32?));
					results = DokumentProvider.GetByIDNacinTransporta(iDNacinTransporta_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDKlijent:
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					results = DokumentProvider.GetByIDKlijent(iDKlijent_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDOrganizacijaZiroRacun:
					iDOrganizacijaZiroRacun_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDOrganizacijaZiroRacun"], typeof(System.Int32?));
					results = DokumentProvider.GetByIDOrganizacijaZiroRacun(iDOrganizacijaZiroRacun_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDValute:
					iDValute_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDValute"], typeof(System.Int32?));
					results = DokumentProvider.GetByIDValute(iDValute_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDOrganizacijaOd:
					iDOrganizacijaOd_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDOrganizacijaOd"], typeof(System.Int32?));
					results = DokumentProvider.GetByIDOrganizacijaOd(iDOrganizacijaOd_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDOrganizacijaPrema:
					iDOrganizacijaPrema_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDOrganizacijaPrema"], typeof(System.Int32?));
					results = DokumentProvider.GetByIDOrganizacijaPrema(iDOrganizacijaPrema_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDDokumentTip:
					iDDokumentTip = ( values["IDDokumentTip"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDDokumentTip"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByIDDokumentTip(iDDokumentTip, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDUserPrimio:
					iDUserPrimio_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDUserPrimio"], typeof(System.Int32?));
					results = DokumentProvider.GetByIDUserPrimio(iDUserPrimio_nullable, this.StartIndex, this.PageSize, out count);
					break;
				// M:M
				case DokumentSelectMethod.GetByIDParentFromVeza:
					iDParent = ( values["IDParent"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDParent"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByIDParentFromVeza(iDParent, this.StartIndex, this.PageSize, out count);
					break;
				case DokumentSelectMethod.GetByIDChildFromVeza:
					iDChild = ( values["IDChild"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDChild"], typeof(System.Int32)) : (int)0;
					results = DokumentProvider.GetByIDChildFromVeza(iDChild, this.StartIndex, this.PageSize, out count);
					break;
				// Custom
				case DokumentSelectMethod.Get_Bez_Veze_ID:
					sp36_IDDokumentToFind = (System.Int32?) EntityUtil.ChangeType(values["@IDDokumentToFind"], typeof(System.Int32?));
					results = DokumentProvider.Get_Bez_Veze_ID(sp36_IDDokumentToFind, StartIndex, PageSize);
					break;
				case DokumentSelectMethod.GetHasStorno:
					sp39_IDDokument = (System.Int32?) EntityUtil.ChangeType(values["@IDDokument"], typeof(System.Int32?));
					sp39_IDDokumentTipStorno = (System.Int32?) EntityUtil.ChangeType(values["@IDDokumentTipStorno"], typeof(System.Int32?));
					results = DokumentProvider.GetHasStorno(sp39_IDDokument, sp39_IDDokumentTipStorno, StartIndex, PageSize);
					break;
				case DokumentSelectMethod.Get_Bez_Veze_DatumOd:
					sp35_DatumOd = (System.DateTime?) EntityUtil.ChangeType(values["@DatumOd"], typeof(System.DateTime?));
					results = DokumentProvider.Get_Bez_Veze_DatumOd(sp35_DatumOd, StartIndex, PageSize);
					break;
				case DokumentSelectMethod.Get_Revers_Nema_Povrat:
					results = DokumentProvider.Get_Revers_Nema_Povrat(StartIndex, PageSize);
					break;
				case DokumentSelectMethod.Get_Bez_Veze:
					results = DokumentProvider.Get_Bez_Veze(StartIndex, PageSize);
					break;
				case DokumentSelectMethod.Get_Revers_Nema_Povrat_Po_ID:
					sp38_IDReversToFind = (System.Int32?) EntityUtil.ChangeType(values["@IDReversToFind"], typeof(System.Int32?));
					results = DokumentProvider.Get_Revers_Nema_Povrat_Po_ID(sp38_IDReversToFind, StartIndex, PageSize);
					break;
				default:
					break;
			}

			if ( results != null && count < 1 )
			{
				count = results.Count;

				if ( !String.IsNullOrEmpty(CustomMethodRecordCountParamName) )
				{
					object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));
					
					if ( objCustomCount != null )
					{
						count = (int) objCustomCount;
					}
				}
			}
			
			return results;
		}
		
		/// <summary>
		/// Gets the values of any supplied parameters for internal caching.
		/// </summary>
		/// <param name="values">An IDictionary object of name/value pairs.</param>
		protected override void GetSelectParameters(IDictionary values)
		{
			if ( SelectMethod == DokumentSelectMethod.Get || SelectMethod == DokumentSelectMethod.GetByID )
			{
				EntityId = GetEntityKey(values);
			}
		}

		/// <summary>
		/// Performs a DeepLoad operation for the current entity if it has
		/// not already been performed.
		/// </summary>
		internal override void DeepLoad()
		{
			if ( !IsDeepLoaded )
			{
				Dokument entity = GetCurrentEntity();
				
				if ( entity != null )
				{
					// init transaction manager
					GetTransactionManager();
					// execute deep load method
					DokumentProvider.DeepLoad(GetCurrentEntity(), EnableRecursiveDeepLoad);
					// set loaded flag
					IsDeepLoaded = true;
				}
			}
		}

		/// <summary>
		/// Performs a DeepLoad operation on the specified entity collection.
		/// </summary>
		/// <param name="entityList"></param>
		/// <param name="properties"></param>
		internal override void DeepLoad(TList<Dokument> entityList, ProviderDataSourceDeepLoadList properties)
		{
			// init transaction manager
			GetTransactionManager();
			// execute deep load method
			DokumentProvider.DeepLoad(entityList, properties.Recursive, properties.Method, properties.GetTypes());
		}

		#endregion Select Methods
	}
	
	#region DokumentDataSourceDesigner

	/// <summary>
	/// Provides design-time support in a design host for the DokumentDataSource class.
	/// </summary>
	public class DokumentDataSourceDesigner : ProviderDataSourceDesigner<Dokument, DokumentKey>
	{
		/// <summary>
		/// Initializes a new instance of the DokumentDataSourceDesigner class.
		/// </summary>
		public DokumentDataSourceDesigner()
		{
		}

		/// <summary>
		/// Gets or sets the SelectMethod property.
		/// </summary>
		public DokumentSelectMethod SelectMethod
		{
			get { return ((DokumentDataSource) DataSource).SelectMethod; }
			set { SetPropertyValue("SelectMethod", value); }
		}

		/// <summary>Gets the designer action list collection for this designer.</summary>
		/// <returns>The <see cref="T:System.ComponentModel.Design.DesignerActionListCollection"/>
		/// associated with this designer.</returns>
		public override DesignerActionListCollection ActionLists
		{
			get
			{
				DesignerActionListCollection actions = new DesignerActionListCollection();
				actions.Add(new DokumentDataSourceActionList(this));
				actions.AddRange(base.ActionLists);
				return actions;
			}
		}
	}

	#region DokumentDataSourceActionList

	/// <summary>
	/// Supports the DokumentDataSourceDesigner class.
	/// </summary>
	internal class DokumentDataSourceActionList : DesignerActionList
	{
		private DokumentDataSourceDesigner _designer;

		/// <summary>
		/// Initializes a new instance of the DokumentDataSourceActionList class.
		/// </summary>
		/// <param name="designer"></param>
		public DokumentDataSourceActionList(DokumentDataSourceDesigner designer) : base(designer.Component)
		{
			_designer = designer;
		}

		/// <summary>
		/// Gets or sets the SelectMethod property.
		/// </summary>
		public DokumentSelectMethod SelectMethod
		{
			get { return _designer.SelectMethod; }
			set { _designer.SelectMethod = value; }
		}

		/// <summary>
		/// Returns the collection of <see cref="T:System.ComponentModel.Design.DesignerActionItem"/>
		/// objects contained in the list.
		/// </summary>
		/// <returns>A <see cref="T:System.ComponentModel.Design.DesignerActionItem"/>
		/// array that contains the items in this list.</returns>
		public override DesignerActionItemCollection GetSortedActionItems()
		{
			DesignerActionItemCollection items = new DesignerActionItemCollection();
			items.Add(new DesignerActionPropertyItem("SelectMethod", "Select Method", "Methods"));
			return items;
		}
	}

	#endregion DokumentDataSourceActionList
	
	#endregion DokumentDataSourceDesigner
	
	#region DokumentSelectMethod
	
	/// <summary>
	/// Enumeration of method names available for the DokumentDataSource.SelectMethod property.
	/// </summary>
	public enum DokumentSelectMethod
	{
		/// <summary>
		/// Represents the Get method.
		/// </summary>
		Get,
		/// <summary>
		/// Represents the GetAll method.
		/// </summary>
		GetAll,
		/// <summary>
		/// Represents the GetPaged method.
		/// </summary>
		GetPaged,
		/// <summary>
		/// Represents the Find method.
		/// </summary>
		Find,
		/// <summary>
		/// Represents the GetByID method.
		/// </summary>
		GetByID,
		/// <summary>
		/// Represents the GetByIDDokumentTipIDStatusIDDatum method.
		/// </summary>
		GetByIDDokumentTipIDStatusIDDatum,
		/// <summary>
		/// Represents the GetByIDStatusIDIDDokumentTipDatum method.
		/// </summary>
		GetByIDStatusIDIDDokumentTipDatum,
		/// <summary>
		/// Represents the GetByIDStatus method.
		/// </summary>
		GetByIDStatus,
		/// <summary>
		/// Represents the GetByDokumentMijenjaCijenuDatumDateModifiedIDIDStatusIDDokumentTip method.
		/// </summary>
		GetByDokumentMijenjaCijenuDatumDateModifiedIDIDStatusIDDokumentTip,
		/// <summary>
		/// Represents the GetByIDIDDokumentTip method.
		/// </summary>
		GetByIDIDDokumentTip,
		/// <summary>
		/// Represents the GetByIDDokumentTipIDIDStatus method.
		/// </summary>
		GetByIDDokumentTipIDIDStatus,
		/// <summary>
		/// Represents the GetByDatumIDDokumentTipIDStatusIDDateModified method.
		/// </summary>
		GetByDatumIDDokumentTipIDStatusIDDateModified,
		/// <summary>
		/// Represents the GetByIDStatusDatumIDDokumentTipIDDateModified method.
		/// </summary>
		GetByIDStatusDatumIDDokumentTipIDDateModified,
		/// <summary>
		/// Represents the GetByIDDokumentTipIDStatusDatumIDDateModified method.
		/// </summary>
		GetByIDDokumentTipIDStatusDatumIDDateModified,
		/// <summary>
		/// Represents the GetByIDDokumentTipIDStatusDatumID method.
		/// </summary>
		GetByIDDokumentTipIDStatusDatumID,
		/// <summary>
		/// Represents the GetByIDUserIzdao method.
		/// </summary>
		GetByIDUserIzdao,
		/// <summary>
		/// Represents the GetByIDNacinPlacanja method.
		/// </summary>
		GetByIDNacinPlacanja,
		/// <summary>
		/// Represents the GetByIDNacinTransporta method.
		/// </summary>
		GetByIDNacinTransporta,
		/// <summary>
		/// Represents the GetByIDKlijent method.
		/// </summary>
		GetByIDKlijent,
		/// <summary>
		/// Represents the GetByIDOrganizacijaZiroRacun method.
		/// </summary>
		GetByIDOrganizacijaZiroRacun,
		/// <summary>
		/// Represents the GetByIDValute method.
		/// </summary>
		GetByIDValute,
		/// <summary>
		/// Represents the GetByIDOrganizacijaOd method.
		/// </summary>
		GetByIDOrganizacijaOd,
		/// <summary>
		/// Represents the GetByIDOrganizacijaPrema method.
		/// </summary>
		GetByIDOrganizacijaPrema,
		/// <summary>
		/// Represents the GetByIDDokumentTip method.
		/// </summary>
		GetByIDDokumentTip,
		/// <summary>
		/// Represents the GetByIDUserPrimio method.
		/// </summary>
		GetByIDUserPrimio,
		/// <summary>
		/// Represents the GetByIDParentFromVeza method.
		/// </summary>
		GetByIDParentFromVeza,
		/// <summary>
		/// Represents the GetByIDChildFromVeza method.
		/// </summary>
		GetByIDChildFromVeza,
		/// <summary>
		/// Represents the Get_Bez_Veze_ID method.
		/// </summary>
		Get_Bez_Veze_ID,
		/// <summary>
		/// Represents the GetHasStorno method.
		/// </summary>
		GetHasStorno,
		/// <summary>
		/// Represents the Get_Bez_Veze_DatumOd method.
		/// </summary>
		Get_Bez_Veze_DatumOd,
		/// <summary>
		/// Represents the Get_Revers_Nema_Povrat method.
		/// </summary>
		Get_Revers_Nema_Povrat,
		/// <summary>
		/// Represents the Get_Bez_Veze method.
		/// </summary>
		Get_Bez_Veze,
		/// <summary>
		/// Represents the Get_Revers_Nema_Povrat_Po_ID method.
		/// </summary>
		Get_Revers_Nema_Povrat_Po_ID
	}
	
	#endregion DokumentSelectMethod

	#region DokumentFilter
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilter&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Dokument"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class DokumentFilter : SqlFilter<DokumentColumn>
	{
	}
	
	#endregion DokumentFilter

	#region DokumentExpressionBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlExpressionBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Dokument"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class DokumentExpressionBuilder : SqlExpressionBuilder<DokumentColumn>
	{
	}
	
	#endregion DokumentExpressionBuilder	

	#region DokumentProperty
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ChildEntityProperty&lt;DokumentChildEntityTypes&gt;"/> class
	/// that is used exclusively with a <see cref="Dokument"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class DokumentProperty : ChildEntityProperty<DokumentChildEntityTypes>
	{
	}
	
	#endregion DokumentProperty
}

